<?php

	/*
	 * 
	 * Reg expression to get different fields from pages 
	 * 
 	 * @author Andrew (Jun Gu), Bo
 	 */

	/*
	 * ========================================================
	 * Add Product Status
	 * ========================================================
	 */
	define("ADDPRODUCT_STATUS_SUCCESS",1);
	define("ADDPRODUCT_STATUS_MISS_KEY_DATA",2);
	define("ADDPRODUCT_STATUS_MISS_REG_DATA",3);	
	define("ADDPRODUCT_STATUS_MISS_TAOBAOAPI_DATA",4);	
	define("PRODUCT_FORBIDDEN", 9);
	/*
	 * ========================================================
	 * Add Shop Status, For verify
	 * ========================================================
	 */	
	define("ADDSHOP_STATUS_MISS_KEY_DATA",2);
	define("ADDSHOP_STATUS_UNKOWNN_PLATFORM",5);
	define("SHOP_FORBIDDEN", 9);
	/*
	 * ========================================================
	 * Taobao --- Product
	 * ========================================================
	 */
	//*0或多次
	//?0或1
	//+1或多
	//\D非数字字符
	define("TAOBAO_ENCODING","GBK");
	
	//从html中获取productID
	define("TAOBAO_CONTENT_PRODUCTID","/itemId=([0-9A-Za-z]+)/");
	
	//从html中获取productNumID
	define("TAOBAO_CONTENT_PRODUCTNUMID","/item_id_num\"\s*value=\"([0-9]+)\"/");
	define("TAOBAO_CONTENT_PRODUCTNUMID1","/add_collection\.htm\?id=([0-9]+)/");;

    //从url中获取productNumID
    define("TAOBAO_URL", "/http:\/\/(item|detail)\.taobao\.com\/item\.htm\?[^&]*&?id=[0-9]+\D*/");
    define("TAOBAO_URL_PRODUCTNUMID", "/id=([0-9]+)/");

    define("TAOBAO_URL1", "/http:\/\/item\.taobao\.com\/auction\/item_detail\.htm\?item_num_id=[0-9]+\D*/");
    define("TAOBAO_URL1_PRODUCTNUMID", "/item_num_id=([0-9]+)/");

    // http://item.tmall.com/item.htm?id=12773937085
    define("TMALL_URL", "/http:\/\/(item|detail)\.tmall.com\/item\.htm\?[^&]*&?id=[0-9]+\D*/");
    define("TMALL_URL_PRODUCTNUMID", "/id=([0-9]+)/");

	define('TAOBAOKE_ID','10176789');
	/*
	 * ========================================================
	 * Eachnet --- Product
	 * ========================================================
	 */
	
	define("EACHNET_ENCODING","utf-8");

	//从html中获取productID
	define("EACHNET_CONTENT_PRODUCTID","/物品号：\s*(\S*)\s*<\/p>/");
	
	define("EACHNET_NICK_NAME","/var\s*webchater\s*=\s*'(\S*)'/");
	define("EACHNET_PRODUCT_NAME","/<h1>\s*(.+)\s*<\/h1>/");
	define("EACHNET_PRODUCT_PRICE","/formatPrice\('([^']*)/");
	
	
	/*
	 * ========================================================
	 * Paipai --- Product
	 * ========================================================
	 */
	
	define("PAIPAI_ENCODING","gb2312");
	
	//从html中获取productID
	define("PAIPAI_CONTENT_PRODUCTID","/\.com\/(\S*)\"\s*title=\"".mb_convert_encoding("商品详情",PAIPAI_ENCODING,"auto")."\"/");	
	
	define("PAIPAI_NICK_NAME","/sellerUin\"\s*value=\"(.+)\"/");
	define("PAIPAI_PRODUCT_NAME","/<h1><!\-\-".mb_convert_encoding("商品标题",PAIPAI_ENCODING,"auto")."\-\->\s*([^<]+)\s*/");	
	define("PAIPAI_PRODUCT_PIC","/picList:\[\[\"([^\"]+)/");
	define("PAIPAI_PRODUCT_PRICE","/<em\s*id=\"commodityCurrentPrice\"\s*defaultVal=\"([^\"]+)/");

	
	/*
	 * ========================================================
	 * Youa --- Product
	 * ========================================================
	 */
	
	define("YOUA_ENCODING","gb2312");
	
	//从html中获取productID
	define("YOUA_CONTENT_PRODUCTID","/favo_obj_id=\"(\S*)\"/");
	
	define("YOUA_NICK_NAME","/uname=\"([^\"]+)/");
	define("YOUA_PRODUCT_NAME","/cls\">\s*<h1>([\S\s]*)<\/h1>/");
	define("YOUA_PRODUCT_PIC","/background\-image:url\(([^\)]+)/");
	define("YOUA_PRODUCT_PRICE","/var\s*price\s*=\s*(\S*);/");
	define("YOUA_PRODUCT_LOCATION","/<td\s*class=\"sdesc\">(\S*)<\/td>/");
	

	/*
	 * ========================================================
	 * dangdang --- Product 101
	 * ========================================================
	 */	
	//http://product.dangdang.com/product.aspx?product_id=1049740901#ref=www-0-M
	//http://product.dangdang.com/product.aspx?product_id=20895218#ref=www-0-Q	
	define("DANGDANG_URL","/http:\/\/product\.dangdang\.com\/product\.aspx\?product_id=[0-9]+\D*/");
	define("DANGDANG_URL_PRODUCTNUMID","/product_id=([0-9]+)/");
	define("DANGDANG_PRODUCTID","/pid=([0-9]+)\"/"); //不适用于当当非c2c商品

	/*
	 * ========================================================
	 * amazon --- Product 102
	 * ========================================================
	 */	
	//http://www.amazon.cn/gp/product/B003O0NKKU/ref=s9_hps_gw_ir01/480-2274467-2674635?pf_rd_m=A1AJ19PSB66TGU&pf_rd_s=center-2&pf_rd_r=110P16SHJF6S60KMCQW6&pf_rd_t=101&pf_rd_p=58493152&pf_rd_i=899254051
	define("AMAZON_URL","/http:\/\/www\.amazon\.cn\/gp\/product\/\S*\/ref=\S*/");
	define("AMAZON_URL_PRODUCTNUMID","/product\/(\S*)\/ref=/");
	define("AMAZON_PRODUCTID","/ASIN:<\/b>\s*(\S*)<\/li>/");	
	/*
	 * ========================================================
	 * 360buy --- Product 103
	 * ========================================================
	 */	
	//http://www.360buy.com/product/208235.html
	define("360BUY_URL","/http:\/\/www\.360buy\.com\/product\/[0-9]+\.html\D*/");
	define("360BUY_URL_PRODUCTNUMID","/product\/([0-9]+)/");
	define("360BUY_PRODUCTID","/".mb_convert_encoding("商品编号：","gb2312","auto")."\s*([0-9]+)</");//注意后面不要带\s*

	/*
	 * ========================================================
	 * yihaodian --- Product 104
	 * ========================================================
	 */	
	//http://www.yihaodian.com/product/detail.do?productID=29206&merchantID=1
	define("YIHAODIAN_URL","/http:\/\/www\.yihaodian\.com\/product\/detail\.do\?productID=[0-9]+\D*/");
	define("YIHAODIAN_URL_PRODUCTNUMID","/productID=([0-9]+)/");	
	define("YIHAODIAN_PRODUCTID","/buyListing\.productId=([0-9]+)&buyListing\.merchantId/");		

?>
